#!/bin/sh

#RPM

set -e

GROUP='stratio'
USER='decision'

if [ "$1" = "2" ]; then
   service decision stop
fi

# Add stratio group if it doesn't already exists
if ! getent group $GROUP >/dev/null 2>&1; then
groupadd ${GROUP}
fi

# Add stratio user if it doesn't already exists
if ! getent passwd $USER >/dev/null 2>&1; then
[ -d /opt ] || mkdir /opt
useradd -M -d /opt/sds -g ${GROUP} -s /bin/bash ${USER}
else
usermod -G $GROUP $USER
fi

exit 0